import type { NextApiRequest, NextApiResponse } from 'next';

// export default function handler(req: NextApiRequest, res: NextApiResponse) {
//   res.status(200).json({ message: 'helloworld' })
// }

import { NextResponse } from "next/server";

// import { PrismaClient } from "@prisma/client";

// const prisma = new PrismaClient();

// Notice the function definition:
export async function POST(req: any) {
  return NextResponse.json(
    { error: "Method not allowed" },
    {
      status: 405
    }
  );
}

// Notice the function definition:
export async function GET(req: any) {
  try {
    // Get all admins using Prisma
    // const admins = await prisma.admin.findMany();

    return NextResponse.json({
      status: 200,
      message: 'helloworld'
    });
  } catch (error) {
    return NextResponse.json(
      { error: "Failed to get admins" },
      {
        status: 500,
      }
    );
  }
}

// import { NextResponse } from "next/server";

// const appendCORS = (resp: NextResponse) => {
//   resp.headers.append("Access-Control-Allow-Credentials", "true");
//   resp.headers.append("Access-Control-Allow-Origin", "*");
//   resp.headers.append("Access-Control-Allow-Methods", "GET,DELETE,PATCH,POST,PUT");
//   resp.headers.append("Access-Control-Allow-Headers", "*");
//   return resp;
// };

// const setContentType = (resp: NextResponse, body: string) => {
//   resp.headers.set("Content-Type", "application/json; charset=UTF-8");
//   resp.headers.set("Content-Length", Buffer.from(body).byteLength + "");
//   return resp;
// };

// export function GET() {
//   const body = JSON.stringify({ status: 1 });
//   const resp = new NextResponse(body);
//   return appendCORS(setContentType(resp, body));
// }
